package org.ellisande.grid.tags;

import javax.servlet.jsp.JspWriter;

import org.ellisande.grid.tags.support.TagBuilder;
import org.ellisande.tld.annotations.Attribute;
import org.ellisande.tld.annotations.Description;
import org.ellisande.tld.annotations.Info;
import org.ellisande.tld.annotations.Required;
import org.ellisande.tld.annotations.Tag;

@Tag(bodyContent = Tag.BodyContent.SCRIPTLESS)
@Info("Creates cells inside a row. Works based on a 12 column grid system.")
public class CellTag extends AbstractTag {

	private static final long serialVersionUID = 6727163528922771011L;

	@Attribute
	@Required
	@Description("Int representation of how many columns this cell should span. Allowed values: 1-12.")
	private String span;


	@Override
	public void startTag() throws Exception {
		TagBuilder tag = createTagBuilder("div");
		JspWriter out = pageContext.getOut();
		tag.addStyle("span" + span);
		out.println(tag.compileStartTag());
	}

	@Override
	public void endTag() throws Exception {
		TagBuilder tag = createTagBuilder("div");
		JspWriter out = pageContext.getOut();
		out.println(tag.compileEndTag());
	}

	@Override
	public void release() {
		super.release();
		span = null;
	}

	public String getSpan() {
		return span;
	}

	public void setSpan(String span) {
		this.span = span;
	}
}
